package com.cn.jinl.controller;


import com.cn.jinl.api.IAbandonMaterialService;
import com.cn.jinl.domain.AbandonMaterial;
import com.cn.jinl.domain.GongxuVo;
import com.cn.jinl.utils.CommonUtil;
import com.cn.jinl.utils.JsonResponse;
import com.cn.jinl.utils.QueryForm;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("/abandon")
public class AbandonMaterialController {

    @Autowired
    private IAbandonMaterialService abandonMaterialService;

    @RequestMapping("/getAbandonMaterialList/{frontToken}")
    @ResponseBody
    public JsonResponse<List<AbandonMaterial>> getAbandonMaterialList(QueryForm queryForm, @PathVariable(value = "frontToken",required = true) String frontToken) throws Exception {
        JsonResponse<List<AbandonMaterial>> response = new JsonResponse<List<AbandonMaterial>>();
        List<AbandonMaterial> list  = abandonMaterialService.getAbandonMaterialList(queryForm);
        response.setResult(list);
        response.setSuccess(true);
        return  response;
    }

    @ResponseBody
    @RequestMapping("/api/addAbandonMaterial")
    public JsonResponse<String> addAbandonMaterial(AbandonMaterial abandonMaterial) throws Exception {
        JsonResponse<String> response = new JsonResponse<String>();
        String result = abandonMaterialService.addAbandonMaterial(abandonMaterial);
        return CommonUtil.getResponseData(response,result);
    }

    @RequestMapping("/api/getAPIAbandonMaterialList")
    @ResponseBody
    public JsonResponse<List<AbandonMaterial>> getAPIAbandonMaterialList() throws Exception {
        JsonResponse<List<AbandonMaterial>> response = new JsonResponse<List<AbandonMaterial>>();
        List<AbandonMaterial> list  = abandonMaterialService.getAPIAbandonMaterialList();
        response.setResult(list);
        response.setSuccess(true);
        return  response;
    }

    @RequestMapping("/api/getGongXuList")
    @ResponseBody
    public JsonResponse<List<GongxuVo>> getGongXuList() throws Exception {
        JsonResponse<List<GongxuVo>> response = new JsonResponse<List<GongxuVo>>();
        List<GongxuVo> list  = abandonMaterialService.getGongXuList();
        response.setResult(list);
        response.setSuccess(true);
        return  response;
    }

}
